#include "board.h"
#include "bflb_gpio.h"
#include "mini_ws2812b.h"
#include "bflb_mtimer.h"


int main(void)
{
  board_init();
  // 初始化ws2812b 数据引脚:18 灯珠数量:1 灯珠类型:GRB
  ws2812b_init(18, 100, WS2812B_TYPE_GRB);
  if (ws2812b_isReady())
  {
    printf("init OK\r\n");
  }

  // 颜色变量,蓝色
  uint8_t color[3] = {0, 0, 255};
  // 设置第一个灯珠为蓝色
  ws2812b_setColor(0, color);
  // 发送数据,点亮灯珠
  ws2812b_flush();

  bflb_mtimer_delay_ms(2000);

  uint8_t color2[3] = {65, 0, 0};
  ws2812b_setColors(1, 9, color2);
  // 发送数据,点亮灯珠
  ws2812b_flush();

  ws2812b_setOff(0);
  // 发送数据
  ws2812b_flush();

  bflb_mtimer_delay_ms(2000);

  uint8_t color3[3] = {255, 0, 0};
  ws2812b_setColors(1, 9, color3);
  ws2812b_reset();
  uint8_t color4[3] = {0, 255, 0};
  ws2812b_setColors(1, 9, color4);
  // 发送数据
  ws2812b_flush();
  bflb_mtimer_delay_ms(2000);

  color4[1] = 0;
  color4[2] = 66;
  ws2812b_setColorAll(color4);
  // 发送数据
  ws2812b_flush();

  bflb_mtimer_delay_ms(2000);

  ws2812b_deinit();
  if (!ws2812b_isReady())
  {
    printf("deinit OK\r\n");
  }

  while (1)
  {

  }
  return 0;
}